package zua.program.androidstudioprogram01;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class ForgetPasswordActivity extends AppCompatActivity {
    TextView password_wrong,point_out,input_username_again;
    EditText input_identify_code,edit_password,edit_password_again;
    Button SMS_verification,Email_validation,OK_and_back,get_identify_code;

    //String username,identify_code,password,password_again,username_again;

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_forgetpassword);

        password_wrong = findViewById(R.id.password_wrong);
        input_identify_code = findViewById(R.id.input_identify_code);
        edit_password = findViewById(R.id.edit_password);
        edit_password_again = findViewById(R.id.edit_password_again);
        input_username_again = findViewById(R.id.input_username_again);
        SMS_verification = findViewById(R.id.SMS_verification);
        Email_validation = findViewById(R.id.Email_validation);
        OK_and_back = findViewById(R.id.OK_and_back);
        get_identify_code = findViewById(R.id.get_identify_code);
        point_out = findViewById(R.id.point_out);

        Intent intent_come = getIntent();
        input_username_again.setText(intent_come.getStringExtra("username"));

        SMS_verification.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Email_validation.setEnabled(false);
            }
        });
        Email_validation.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SMS_verification.setEnabled(false);
            }
        });
        get_identify_code.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String username_again = input_username_again.getText().toString();
                point_out.setText(R.string.unavailable);
            }
        });
        OK_and_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String username = input_username_again.getText().toString();
                String identify_code = input_identify_code.getText().toString();
                String password = edit_password.getText().toString();
                String password_again = edit_password_again.getText().toString();
                if ((identify_code.equals("1234567") || identify_code.equals("7654321")) && password.equals(password_again)) {//
                    Intent intent = new Intent(ForgetPasswordActivity.this,MainActivity.class);
                    intent.putExtra("username",username);
                    intent.putExtra("password",password);
                    startActivity(intent);
                } else {
                    Toast.makeText(ForgetPasswordActivity.this,"小可爱，你两次密码输入的不一样哦",Toast.LENGTH_LONG).show();

                }
            }
        });
    }
}
